package servlet;

import bean.Request;
import bean.Response;
import errors.HTTPMethodNotSupportException;
import utils.FileUtils;
import utils.Logger;

import java.io.IOException;
import java.io.PrintWriter;

public class IndexServlet extends Servlet {
    @Override
    public void doGet(Request request, Response response) throws HTTPMethodNotSupportException {
        PrintWriter printWriter  = new PrintWriter(response.getOutputStream());
        try {
            String param = request.getParam("name");
            Logger.println(param);
            String string = new String(FileUtils.readFile("src/templates/index.html"));
            printWriter.println(string);
            printWriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
